{% extends "base.html" %}
{% load comments %}
{% load markup %}

{% block title %}Welcome!{% endblock %}

{% block primary-content %}
<span class="breadcrumbs"><a href="{% url index %}" title="Home">Home</a> &raquo; <a href="{% url blog %}" title="Blog">Blog</a> &raquo; Post</span>
<h2>An {{ location.site.name }} Blog Post</h2>
{% if not_published %}
  <p class="alert">This post is not published. It will not appear elsewhere on the site until it is marked as "active."</p>
{% endif %}
<h3 class="blog">{{ post }}</h3>
<div class="blog-main">
	<small class="date-posted">Posted {{ post.pub_date|date }} by {{ post.get_author }}</small>
	{{ post.body|markdown }}
  {% if post.attachments.all %}
	<h4 class="data"><a id="data" name="data"></a>Attachments</h4>
	<ul>
		{% for attachment in post.attachments.all %}
		<li><a href="{{ attachment.upload.url }}">{{ attachment }}</a></li>
		{% endfor %}
	</ul>	
  {% endif %}
	<ul id="share">
	  <li id="share-twitter"><a title="Share on Twitter" href="http://api.tweetmeme.com/share?url=http://www.ourphiladelphia.org{% url blog_post post.id %}">Twitter</a></li>
	  <li id="share-facebook"><a title="Share on Facebook" href="http://www.facebook.com/share.php?u=http://www.ourphiladelphia.org{% url blog_post post.id %}">Facebook</a></li>
	  <li id="share-delicious"><a title="Share on Delicious" href="http://www.delicious.com/post?url=http://www.ourphiladelphia.org{% url blog_post post.id %}">Delicious</a></li>
	  <li id="share-digg"><a title="Share on Digg" href="http://www.digg.com/submit?phase=2&url=http://www.ourphiladelphia.org{% url blog_post post.id %}">Digg</a></li>		      
	</ul>
</div>
<div class="blog-aside">
{% with post.issues.active as issues %}
{% with post.reps.active as reps %}
  {% include "news/snippets/aside.html" %}
{% endwith %}
{% endwith %}
</div>
{% if older or newer %}
<div class="pager clear-left">
  {% if older %}
  <div class="float-left"><a href="{% url blog_post older.id %}">&laquo; Previous Blog Post</a></div>
  {% endif %}
  {% if newer %}
  <div class="float-right"><a href="{% url blog_post newer.id %}">Next Blog Post &raquo;</a></div>
  {% endif %}
</div>
{% endif %}
{% get_comment_list for post as comments %}
{% if comments %}
<h3 class="clear-left">Comments</h3>
<ol class="comment-list">
  {% for comment in comments %}
  {% if forloop.last %}<a name="last-comment"></a>{% endif %}
  <a name="{{ comment.id }}"></a>
  <li class="comment clearfix">
    <div class="comment-author"> 
			{% if comment.user.get_profile.photo %}
		  <img class="comment-avatar" src="{{ comment.user.get_profile.photo.url }}"/>
		  {% else %}
		  <img class="comment-avatar" src="{{ MEDIA_URL }}images/default-avatar.gif"/>
		  {% endif %}
      <cite class="fn">
        {% if comment.user.get_profile %}
        <a href="{% url profiles_profile_detail comment.user %}" class="url">{{ comment.user_name }}</a>
        {% else %}
        {{ comment.user_name }}
        {% endif %}
      </cite> 
      <small class="date-posted">{{ comment.submit_date|date }}</small>
    </div>
    <div class="comment-body">
      {{ comment.comment|markdown:"safe" }}
    </div>
  </li>
  {% endfor %}
</ol>
{% endif %}
<div class="form-wrapper" id="leave-comment">
  <a name="comment-form"></a>
  {% if user.is_authenticated %}
  <h3>Leave a Comment</h3>
  {% get_comment_form for post as form %}
  <form action="{% comment_form_target %}" class="simple-form" id="commentform" method="POST">
    {% csrf_token %}
    <input name="next" type="hidden" value="{% url blog_post post.id %}#last-comment"/>
    {{ form.content_type }}
    {{ form.object_pk }}
    {{ form.timestamp }}
    {{ form.security_hash }}
    <div class="honeypot">
      <label for="id_honeypot">If you enter anything in this field your comment will be treated as spam.</label>
      {{ form.honeypot }}
    </div>
    <div class="form-item">
      <label for="id_comment">Your comments</label>
      {{ form.comment }}
      <p class="help_text">Use <a href="http://daringfireball.net/projects/markdown/syntax">Markdown</a> for formatting.</p>
    </div>
    <input type="submit" class="button" value="Submit comment" />
  </form>
  {% else %}
  <h3>Log in to Leave a Comment</h3>
  <p><a href="">Sign up</a> for free.</p>
  <form class="simple-form" method="POST" action="{% url auth_login %}">
    {% csrf_token %}
    <input name="next" type="hidden" value="{% url blog_post post.id %}#comment-form"/>
    <div class="form-item">
      <label for="id_username">Username</label>
      <input id="id_username" name="username" type="text" class="text"/>
    </div>
    <div class="form-item">
      <label for="id_password">Password</label>
      <input id="id_password" name="password" type="password" class="text"/>
    </div>
    <input name="submit" type="submit" class="button" value="Submit" />
  </form>
  {% endif %}
</div>
{% endblock %}

{% block secondary-content %}
  {% include "snippets/signup_or_info.html" %}
  {% include "news/snippets/blog_archives.html" %}
  {% include "snippets/reports_and_news.html" %}
{% endblock %}

